import IUserPageVO from '@/model/vo/user/IUserPageVO'
import { previewImg } from '@/util/CommonUtil'
import { getPublicDownFileUrl } from '@/util/UrlUtil'
import { IconRadio } from '@douyinfe/semi-icons'
import { Avatar } from '@douyinfe/semi-ui'

export default [
  {
    title: '头像',
    dataIndex: 'avatarUrl',
    width: 90,
    render: (text: any, record: IUserPageVO, index: number) => {
      return (
        <div title={record.avatarUrl ? '点击预览头像' : ''}>
          <Avatar
            size="small"
            color="light-blue"
            src={getPublicDownFileUrl(record.avatarUrl)}
            onClick={() => {
              if (record.avatarUrl) {
                previewImg(getPublicDownFileUrl(record.avatarUrl))
              }
            }}
          >
            {record.nickname?.slice(0, 1).toUpperCase()}
          </Avatar>
        </div>
      )
    },
  },
  { title: '昵称', dataIndex: 'nickname' },
  { title: '邮箱', dataIndex: 'email' },
  { title: '手机号', dataIndex: 'phone' },
  {
    title: '状态',
    dataIndex: 'enableFlag',
    render: (text: any, record: IUserPageVO, index: number) => {
      return (
        <IconRadio
          title={record.enableFlag ? '账号正常' : '账号冻结中'}
          className={record.enableFlag ? 'green' : 'red'}
        />
      )
    },
  },
  { title: '创建时间', dataIndex: 'createTime', sorter: true },
]
